package handler

import (
	"context"
	"server/basic/global"
	"server/models"
	__ "server/proto"
)

type Server struct {
	__.UnimplementedExamServer
}

// SayHello implements helloworld.GreeterServer
func (s *Server) List(_ context.Context, in *__.ListRequest) (*__.ListResponse, error) {
	var exam []models.Exams
	global.DB.Find(&exam)
	var resp []*__.List
	for _, v := range exam {
		list := &__.List{
			Project: v.Project,
			Types:   v.Types,
			Status:  v.Status,
			Fire:    v.Fire,
			Author:  v.Author,
			Name:    v.Name,
			Data:    v.Data,
		}
		resp = append(resp, list)
	}
	return &__.ListResponse{
		List: resp,
	}, nil
}
